package com.formula.datastructure.exam.queue;

public class Queue<T> {
    T[] array;

    int front = 0;
    int rear = -1;

    public Queue() {
        array = (T[]) new Object[50];
    }

    public boolean isEmpty() {
        return rear < 0 || front < rear;
    }

    public void enqueue(T data) {
        array[++rear] = data;
    }

    public T dequeue() {
        if (front >= rear) {
            T result = array[front++];
            array[front - 1] = null;
            return result;
        }
        return null;
    }

}
